﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TipokHostManager.Configuration
{
    /// <summary>
    /// 配置文件中的heath节点映射
    /// </summary>
    class HeathSection : ConfigurationSection
    {
        private static readonly ConfigurationProperty _machines = new ConfigurationProperty("machines", typeof(MachineElementCollection), null, ConfigurationPropertyOptions.IsRequired);
        private static ConfigurationPropertyCollection _properties = new ConfigurationPropertyCollection();

        static HeathSection()
        {
            _properties.Add(_machines);
        }

        protected override ConfigurationPropertyCollection Properties
        {
            get
            {
                return _properties;
            }
        }

        public List<MachineElement> Machines
        {
            get
            {
                var collection = (MachineElementCollection)base[_machines];
                var list = new List<MachineElement>();
                for (int i = 0; i < collection.Count; i++)
                {
                    list.Add(collection.Get(i));
                }
                return list;
            }
        }
    }
}
